package com.emergency.assist.controller;

import com.emergency.assist.domain.OrderAssign;
import com.emergency.assist.domain.Resource;
import com.emergency.assist.domain.RouteOptimal;
import com.emergency.assist.service.DistributeService;
import com.emergency.base.domain.Plan;
import com.emergency.base.domain.PlanDetail;
import com.emergency.common.entity.Result;
import com.emergency.common.entity.StatusCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Created by qiuyan.pei on 2020/4/1.
 */
@RestController
@RequestMapping("/distribute")
@Api(value="资源调度类",description = "根据拥有资源，为所需单位分配")
public class DistributeController {

    @Autowired
    private DistributeService distributeService;

    @ApiOperation(value = "资源调度接口", notes = "根据拥有资源，为所需单位分配")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "data", value = "路线矩阵数据", required = true, paramType = "query", dataType = "String"),
    })

    @RequestMapping(value = "distribute")
    public Result vehicalDistribute(int grade, int environment, int army) {

        List<Resource> distributeResult = distributeService.getDistribute(grade, environment, army);

        return new Result(true, StatusCode.OK, "分析成功", distributeResult);

    }

    @RequestMapping(value = "scheme/query")//查询方案
    public Result schemeQuery(long scenarId) {

        Plan plans = distributeService.schemeQuery(scenarId);//返回查到的order一列

        return new Result(true, StatusCode.OK, "分析成功", plans);

    }

    @RequestMapping(value = "/assign")//派遣方案
    public Result orderAssignPeople( long orderId) {

        distributeService.orderAssignPeople(orderId);//返回查到的order方案

        List<OrderAssign> orderAssignList=distributeService.orderAssignPeople(orderId);
        return new Result(true, StatusCode.OK, "分析成功", orderAssignList);
    }
}
